[#include "/WEB-INF/pages/common/taglibs.ftl"]
[@c.url var="backurl" value='/manage/Site_cache.action' scope="page" /]
[@c.url	var="deleteUrl" value='/manage/Site_cacheDelete.action' scope="page"]
	[@c.param name="backurl" value="${backurl}"/]
[/@c.url];
	<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<title>Insert title here</title>
			<meta name="menu" content="CategoryMenu"/> 
			<meta name="heading" content="heading"/>
			<script type="text/javascript" src="[@c.url value='/js/plugins/jquery.alerts.js'/]"></script>
			<script type="text/javascript">
				var change = function($input) {
					var status = $input.is(":checked");
					var url = "[@c.url value='/manage/Site_cacheSwitch.action'/]";
					var params = {ajax:true};
					params.allow = status;
					$.get(url, params, function(result, status, respose){
						if (status =='success') {
							jAlert(result.trim(), '提示信息.');
						} else {
							jAlert('操作失败,请联系管理员.', '提示信息.');
						}
					});
				}
			
				var base = (function(){
					// 事件绑定
					function _addEventListeners() {
						// 新增事件
						$('.add').click(function(){
							$(this).parents('label').after($('#addField').html());
							return false;
						})
						$('.delete').live('click', function(){
							$(this).parents('span').fadeOut("slow", function(){
								$(this).html('');
							});
							return false;	
						})
						
						$('.cache-clear').click(function(){
							var url = $(this).attr('href');
							$.get(url, function(data){
								//alert("Data Loaded: " + data);
								jAlert("页面缓存已经清除");
							});
							return false;
						})
					};
					
					function _jqxComponentRender() {
						// 增加子项事件绑定
						$('button', '#addConfigItem').unbind('click').click(function() {
							var size = $('.config_item').length;
							$('#addConfigItem').before("<span class='field config_item'>"
							+"缓存名：<input style='width:80px;' name='webCacheModelList[" + size + "].title' value='' />"
							//+"&nbsp;&nbsp;缓存KEY：<input style='width:80px;' name='webCacheModelList[" + size + "].name' value='' />"
							+"&nbsp;&nbsp;缓存地址：<input style='width:180px;' name='webCacheModelList[" + size + "].url' value='' />"
							+" <a href='javascript:;' style='width:50px;' class='stdbtn radius2 item-delete'>删除</a></span>");
							_itemDeleteEventListener()
							return false;
						})
					}
					
					// item-delete
					function _itemDeleteEventListener() {
						// 删除按钮
						$('.item-delete').unbind().click(function() {
							var _$item = $(this);
							_$item.parents('.config_item').fadeOut("slow", function(){
								$(this).remove();
							})
							return false;
						})
					}
					return {
		                config: {
		                	url : null,
		                    theme: null
		                },
		                init: function () {
		                    _addEventListeners();
		                    _jqxComponentRender();
		                    _itemDeleteEventListener();
		                }
					}
				}());
				
				$(function(){
					var link = "[@c.url value='/manage/Site_cache.action?currentPage=${currentPage}' /]";
					base.config.theme = getTheme();
					base.config.url = link;
		            //Initializing the form
					base.init();
				})
			</script>
		</head>
		<body id="body">
			<div class="contenttitle">
		    	<h2 id="vertical" class="form"><span>页面缓存设置</span></h2>
		    </div><!--contenttitle-->
			<!--设置提交行为-->
			<form action="[@c.url value="/manage/Site_cacheChange.action"][@c.param name="backurl" value="${backurl}"/][/@c.url]" method="post" class="stdform stdform2">
				<p style="background-color:#DDDDDD;">
		        	<label style="text-align:center; width: 80px;">缓存操作</label>
		        	<span class="field" style="background-color:#DDDDDD; height:48px; line-height:48px;">
		        		<input id="cacheStatus" type="checkbox" class="yes_no" rel="{labelOn: '启动', labelOff: '关闭', easing: 'swing', duration: 200, change:change}" name="allow" value="true" [#if allow == true]checked="checked"[/#if]></input>
		        		&nbsp;&nbsp;[ <a target="_bank;" href="[@c.url value='/j_page_cache_info'/]" style="color:#b50000;font-weight:bold;">查看缓存信息</a> ]
		        		&nbsp;&nbsp;|&nbsp;&nbsp;[ <a href="[@c.url value='/j_page_cache_clear'/]" style="color:#b50000;font-weight:bold;" class="cache-clear">清除缓存</a> ]
		            </span>
		        </p>
		        [#list webCacheModelList as cache]
				<p>
		        	<label>名称：<br/>
						<input type="hidden" name="webCacheModelList[${cache_index}].id" value="${cache.id?c}"/>
		            	${cache.allow}<input id="allow_${cache_index}" type="checkbox" [#if cache.isAllow()]checked="checked"[/#if] value="true" name="webCacheModelList[${cache_index}].allow" />
		            	<label style="padding:0; float:none;margin-left:0;font-weight:normal;width:auto;" for="allow_0"> 允许 <span style="color:#0000b5;font-weight:bold;"> ${cache.title!''} </span> 缓存</label>
		            </label>
		            <span class="field config_item" style="height:48px;line-height:48px;">
		            	<input class="smallinput" placeholder="实际地址" name="webCacheModelList[${cache_index}].url" value="${(cache.url)!''}" />
		            	&nbsp;&nbsp;[ <a style="color:#b50000;font-weight:bold;" href="[@c.url value='/manage/Site_cacheDelete.action'][@c.param name="id" value='${cache.ssid}'/][@c.param name='backurl' value='${currentUrl}'/][/@c.url]">删&nbsp;&nbsp;除</a> ]
		            </span>
		        </p>
		        [/#list]
				<p>
		            <span class="field" id="addConfigItem">
		            	<button>增加</button>
					</span>
		        </p>
				<p class="stdformbutton">
			      	<button class="submit ">提&nbsp;&nbsp;交</button>
			        <input type="reset" value="重&nbsp;&nbsp;置" class="reset radius2" />
			        <a class="anchorbutton button_alert" href="${backurl}" style="margin-left:6px;background-color: rgb(247, 247, 247); border-color: rgb(204, 204, 204); color: rgb(51, 51, 51);"><span style="background-color: rgb(255, 255, 255); border-color: rgb(221, 221, 221);">返&nbsp;&nbsp;回</span></a>
			    </p>		
			</form> 
			<div style="clear:both;"></div>
			<script type="text/javascript">
			//<![CDATA[
				$(function(){
					var theme = getTheme();
					//默认源码模式
				})		
			//]]></script>
		</body>
	</html>